package com.example.administrator.kotlintutorial.`class`.proxy

/**
 * Created by chensuilun on 2019/2/22.
 */

//生成 静态代理对象，但是怎么调用代理类的方法啊？
//
//public final class ProxyAnimal implements Animal {
//    private final Animal animal;
//
//    public ProxyAnimal(@NotNull Animal animal) {
//        Intrinsics.checkParameterIsNotNull(animal, "animal");
//        this.animal = animal;
//    }
//
//    public void hello() {
//        System.out.println("Before hello");
//        this.animal.hello();
//        System.out.println("After hello");
//    }
//}

class ProxyAnimal(private val animal: Animal) : Animal by animal {

    override fun hello() {
        println("Before hello")
        animal.hello()
        println("After hello")
    }
}